<?php


/**
 * Base class that represents a query for the 'application_data_defs' table.
 *
 *
 *
 * @method ApplicationDataDefsQuery orderById($order = Criteria::ASC) Order by the id column
 * @method ApplicationDataDefsQuery orderByApplicationDataSetId($order = Criteria::ASC) Order by the application_data_set_id column
 * @method ApplicationDataDefsQuery orderByCode($order = Criteria::ASC) Order by the code column
 * @method ApplicationDataDefsQuery orderByLabel($order = Criteria::ASC) Order by the label column
 * @method ApplicationDataDefsQuery orderByLabelEn($order = Criteria::ASC) Order by the label_en column
 * @method ApplicationDataDefsQuery orderByDescription($order = Criteria::ASC) Order by the description column
 * @method ApplicationDataDefsQuery orderByDescriptionEn($order = Criteria::ASC) Order by the description_en column
 * @method ApplicationDataDefsQuery orderByType($order = Criteria::ASC) Order by the type column
 * @method ApplicationDataDefsQuery orderByValueType($order = Criteria::ASC) Order by the value_type column
 * @method ApplicationDataDefsQuery orderByDefaultValue($order = Criteria::ASC) Order by the default_value column
 * @method ApplicationDataDefsQuery orderByLastModified($order = Criteria::ASC) Order by the last_modified column
 * @method ApplicationDataDefsQuery orderByCreated($order = Criteria::ASC) Order by the created column
 *
 * @method ApplicationDataDefsQuery groupById() Group by the id column
 * @method ApplicationDataDefsQuery groupByApplicationDataSetId() Group by the application_data_set_id column
 * @method ApplicationDataDefsQuery groupByCode() Group by the code column
 * @method ApplicationDataDefsQuery groupByLabel() Group by the label column
 * @method ApplicationDataDefsQuery groupByLabelEn() Group by the label_en column
 * @method ApplicationDataDefsQuery groupByDescription() Group by the description column
 * @method ApplicationDataDefsQuery groupByDescriptionEn() Group by the description_en column
 * @method ApplicationDataDefsQuery groupByType() Group by the type column
 * @method ApplicationDataDefsQuery groupByValueType() Group by the value_type column
 * @method ApplicationDataDefsQuery groupByDefaultValue() Group by the default_value column
 * @method ApplicationDataDefsQuery groupByLastModified() Group by the last_modified column
 * @method ApplicationDataDefsQuery groupByCreated() Group by the created column
 *
 * @method ApplicationDataDefsQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
 * @method ApplicationDataDefsQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
 * @method ApplicationDataDefsQuery innerJoin($relation) Adds a INNER JOIN clause to the query
 *
 * @method ApplicationDataDefsQuery leftJoinApplicationDataSets($relationAlias = null) Adds a LEFT JOIN clause to the query using the ApplicationDataSets relation
 * @method ApplicationDataDefsQuery rightJoinApplicationDataSets($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ApplicationDataSets relation
 * @method ApplicationDataDefsQuery innerJoinApplicationDataSets($relationAlias = null) Adds a INNER JOIN clause to the query using the ApplicationDataSets relation
 *
 * @method ApplicationDataDefsQuery leftJoinUserApplicationData($relationAlias = null) Adds a LEFT JOIN clause to the query using the UserApplicationData relation
 * @method ApplicationDataDefsQuery rightJoinUserApplicationData($relationAlias = null) Adds a RIGHT JOIN clause to the query using the UserApplicationData relation
 * @method ApplicationDataDefsQuery innerJoinUserApplicationData($relationAlias = null) Adds a INNER JOIN clause to the query using the UserApplicationData relation
 *
 * @method ApplicationDataDefs findOne(PropelPDO $con = null) Return the first ApplicationDataDefs matching the query
 * @method ApplicationDataDefs findOneOrCreate(PropelPDO $con = null) Return the first ApplicationDataDefs matching the query, or a new ApplicationDataDefs object populated from the query conditions when no match is found
 *
 * @method ApplicationDataDefs findOneById(int $id) Return the first ApplicationDataDefs filtered by the id column
 * @method ApplicationDataDefs findOneByApplicationDataSetId(int $application_data_set_id) Return the first ApplicationDataDefs filtered by the application_data_set_id column
 * @method ApplicationDataDefs findOneByCode(string $code) Return the first ApplicationDataDefs filtered by the code column
 * @method ApplicationDataDefs findOneByLabel(string $label) Return the first ApplicationDataDefs filtered by the label column
 * @method ApplicationDataDefs findOneByLabelEn(string $label_en) Return the first ApplicationDataDefs filtered by the label_en column
 * @method ApplicationDataDefs findOneByDescription(string $description) Return the first ApplicationDataDefs filtered by the description column
 * @method ApplicationDataDefs findOneByDescriptionEn(string $description_en) Return the first ApplicationDataDefs filtered by the description_en column
 * @method ApplicationDataDefs findOneByType(string $type) Return the first ApplicationDataDefs filtered by the type column
 * @method ApplicationDataDefs findOneByValueType(string $value_type) Return the first ApplicationDataDefs filtered by the value_type column
 * @method ApplicationDataDefs findOneByDefaultValue(string $default_value) Return the first ApplicationDataDefs filtered by the default_value column
 * @method ApplicationDataDefs findOneByLastModified(string $last_modified) Return the first ApplicationDataDefs filtered by the last_modified column
 * @method ApplicationDataDefs findOneByCreated(string $created) Return the first ApplicationDataDefs filtered by the created column
 *
 * @method array findById(int $id) Return ApplicationDataDefs objects filtered by the id column
 * @method array findByApplicationDataSetId(int $application_data_set_id) Return ApplicationDataDefs objects filtered by the application_data_set_id column
 * @method array findByCode(string $code) Return ApplicationDataDefs objects filtered by the code column
 * @method array findByLabel(string $label) Return ApplicationDataDefs objects filtered by the label column
 * @method array findByLabelEn(string $label_en) Return ApplicationDataDefs objects filtered by the label_en column
 * @method array findByDescription(string $description) Return ApplicationDataDefs objects filtered by the description column
 * @method array findByDescriptionEn(string $description_en) Return ApplicationDataDefs objects filtered by the description_en column
 * @method array findByType(string $type) Return ApplicationDataDefs objects filtered by the type column
 * @method array findByValueType(string $value_type) Return ApplicationDataDefs objects filtered by the value_type column
 * @method array findByDefaultValue(string $default_value) Return ApplicationDataDefs objects filtered by the default_value column
 * @method array findByLastModified(string $last_modified) Return ApplicationDataDefs objects filtered by the last_modified column
 * @method array findByCreated(string $created) Return ApplicationDataDefs objects filtered by the created column
 *
 * @package    propel.generator..om
 */
abstract class BaseApplicationDataDefsQuery extends ModelCriteria
{
    /**
     * Initializes internal state of BaseApplicationDataDefsQuery object.
     *
     * @param     string $dbName The dabase name
     * @param     string $modelName The phpName of a model, e.g. 'Book'
     * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
     */
    public function __construct($dbName = 'vgp_hr_app', $modelName = 'ApplicationDataDefs', $modelAlias = null)
    {
        parent::__construct($dbName, $modelName, $modelAlias);
    }

    /**
     * Returns a new ApplicationDataDefsQuery object.
     *
     * @param     string $modelAlias The alias of a model in the query
     * @param     ApplicationDataDefsQuery|Criteria $criteria Optional Criteria to build the query from
     *
     * @return ApplicationDataDefsQuery
     */
    public static function create($modelAlias = null, $criteria = null)
    {
        if ($criteria instanceof ApplicationDataDefsQuery) {
            return $criteria;
        }
        $query = new ApplicationDataDefsQuery();
        if (null !== $modelAlias) {
            $query->setModelAlias($modelAlias);
        }
        if ($criteria instanceof Criteria) {
            $query->mergeWith($criteria);
        }

        return $query;
    }

    /**
     * Find object by primary key.
     * Propel uses the instance pool to skip the database if the object exists.
     * Go fast if the query is untouched.
     *
     * <code>
     * $obj  = $c->findPk(12, $con);
     * </code>
     *
     * @param mixed $key Primary key to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return   ApplicationDataDefs|ApplicationDataDefs[]|mixed the result, formatted by the current formatter
     */
    public function findPk($key, $con = null)
    {
        if ($key === null) {
            return null;
        }
        if ((null !== ($obj = ApplicationDataDefsPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
            // the object is alredy in the instance pool
            return $obj;
        }
        if ($con === null) {
            $con = Propel::getConnection(ApplicationDataDefsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        if ($this->formatter || $this->modelAlias || $this->with || $this->select
         || $this->selectColumns || $this->asColumns || $this->selectModifiers
         || $this->map || $this->having || $this->joins) {
            return $this->findPkComplex($key, $con);
        } else {
            return $this->findPkSimple($key, $con);
        }
    }

    /**
     * Find object by primary key using raw SQL to go fast.
     * Bypass doSelect() and the object formatter by using generated code.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return   ApplicationDataDefs A model object, or null if the key is not found
     * @throws   PropelException
     */
    protected function findPkSimple($key, $con)
    {
        $sql = 'SELECT ID, APPLICATION_DATA_SET_ID, CODE, LABEL, LABEL_EN, DESCRIPTION, DESCRIPTION_EN, TYPE, VALUE_TYPE, DEFAULT_VALUE, LAST_MODIFIED, CREATED FROM application_data_defs WHERE ID = :p0';
        try {
            $stmt = $con->prepare($sql);
            $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
        }
        $obj = null;
        if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
            $obj = new ApplicationDataDefs();
            $obj->hydrate($row);
            ApplicationDataDefsPeer::addInstanceToPool($obj, (string) $key);
        }
        $stmt->closeCursor();

        return $obj;
    }

    /**
     * Find object by primary key.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return ApplicationDataDefs|ApplicationDataDefs[]|mixed the result, formatted by the current formatter
     */
    protected function findPkComplex($key, $con)
    {
        // As the query uses a PK condition, no limit(1) is necessary.
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKey($key)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
    }

    /**
     * Find objects by primary key
     * <code>
     * $objs = $c->findPks(array(12, 56, 832), $con);
     * </code>
     * @param     array $keys Primary keys to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return PropelObjectCollection|ApplicationDataDefs[]|mixed the list of results, formatted by the current formatter
     */
    public function findPks($keys, $con = null)
    {
        if ($con === null) {
            $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKeys($keys)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->format($stmt);
    }

    /**
     * Filter the query by primary key
     *
     * @param     mixed $key Primary key to use for the query
     *
     * @return ApplicationDataDefsQuery The current query, for fluid interface
     */
    public function filterByPrimaryKey($key)
    {

        return $this->addUsingAlias(ApplicationDataDefsPeer::ID, $key, Criteria::EQUAL);
    }

    /**
     * Filter the query by a list of primary keys
     *
     * @param     array $keys The list of primary key to use for the query
     *
     * @return ApplicationDataDefsQuery The current query, for fluid interface
     */
    public function filterByPrimaryKeys($keys)
    {

        return $this->addUsingAlias(ApplicationDataDefsPeer::ID, $keys, Criteria::IN);
    }

    /**
     * Filter the query on the id column
     *
     * Example usage:
     * <code>
     * $query->filterById(1234); // WHERE id = 1234
     * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
     * $query->filterById(array('min' => 12)); // WHERE id > 12
     * </code>
     *
     * @param     mixed $id The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return ApplicationDataDefsQuery The current query, for fluid interface
     */
    public function filterById($id = null, $comparison = null)
    {
        if (is_array($id) && null === $comparison) {
            $comparison = Criteria::IN;
        }

        return $this->addUsingAlias(ApplicationDataDefsPeer::ID, $id, $comparison);
    }

    /**
     * Filter the query on the application_data_set_id column
     *
     * Example usage:
     * <code>
     * $query->filterByApplicationDataSetId(1234); // WHERE application_data_set_id = 1234
     * $query->filterByApplicationDataSetId(array(12, 34)); // WHERE application_data_set_id IN (12, 34)
     * $query->filterByApplicationDataSetId(array('min' => 12)); // WHERE application_data_set_id > 12
     * </code>
     *
     * @see       filterByApplicationDataSets()
     *
     * @param     mixed $applicationDataSetId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return ApplicationDataDefsQuery The current query, for fluid interface
     */
    public function filterByApplicationDataSetId($applicationDataSetId = null, $comparison = null)
    {
        if (is_array($applicationDataSetId)) {
            $useMinMax = false;
            if (isset($applicationDataSetId['min'])) {
                $this->addUsingAlias(ApplicationDataDefsPeer::APPLICATION_DATA_SET_ID, $applicationDataSetId['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($applicationDataSetId['max'])) {
                $this->addUsingAlias(ApplicationDataDefsPeer::APPLICATION_DATA_SET_ID, $applicationDataSetId['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(ApplicationDataDefsPeer::APPLICATION_DATA_SET_ID, $applicationDataSetId, $comparison);
    }

    /**
     * Filter the query on the code column
     *
     * Example usage:
     * <code>
     * $query->filterByCode('fooValue');   // WHERE code = 'fooValue'
     * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
     * </code>
     *
     * @param     string $code The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return ApplicationDataDefsQuery The current query, for fluid interface
     */
    public function filterByCode($code = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($code)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $code)) {
                $code = str_replace('*', '%', $code);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(ApplicationDataDefsPeer::CODE, $code, $comparison);
    }

    /**
     * Filter the query on the label column
     *
     * Example usage:
     * <code>
     * $query->filterByLabel('fooValue');   // WHERE label = 'fooValue'
     * $query->filterByLabel('%fooValue%'); // WHERE label LIKE '%fooValue%'
     * </code>
     *
     * @param     string $label The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return ApplicationDataDefsQuery The current query, for fluid interface
     */
    public function filterByLabel($label = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($label)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $label)) {
                $label = str_replace('*', '%', $label);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(ApplicationDataDefsPeer::LABEL, $label, $comparison);
    }

    /**
     * Filter the query on the label_en column
     *
     * Example usage:
     * <code>
     * $query->filterByLabelEn('fooValue');   // WHERE label_en = 'fooValue'
     * $query->filterByLabelEn('%fooValue%'); // WHERE label_en LIKE '%fooValue%'
     * </code>
     *
     * @param     string $labelEn The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return ApplicationDataDefsQuery The current query, for fluid interface
     */
    public function filterByLabelEn($labelEn = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($labelEn)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $labelEn)) {
                $labelEn = str_replace('*', '%', $labelEn);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(ApplicationDataDefsPeer::LABEL_EN, $labelEn, $comparison);
    }

    /**
     * Filter the query on the description column
     *
     * Example usage:
     * <code>
     * $query->filterByDescription('fooValue');   // WHERE description = 'fooValue'
     * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
     * </code>
     *
     * @param     string $description The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return ApplicationDataDefsQuery The current query, for fluid interface
     */
    public function filterByDescription($description = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($description)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $description)) {
                $description = str_replace('*', '%', $description);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(ApplicationDataDefsPeer::DESCRIPTION, $description, $comparison);
    }

    /**
     * Filter the query on the description_en column
     *
     * Example usage:
     * <code>
     * $query->filterByDescriptionEn('fooValue');   // WHERE description_en = 'fooValue'
     * $query->filterByDescriptionEn('%fooValue%'); // WHERE description_en LIKE '%fooValue%'
     * </code>
     *
     * @param     string $descriptionEn The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return ApplicationDataDefsQuery The current query, for fluid interface
     */
    public function filterByDescriptionEn($descriptionEn = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($descriptionEn)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $descriptionEn)) {
                $descriptionEn = str_replace('*', '%', $descriptionEn);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(ApplicationDataDefsPeer::DESCRIPTION_EN, $descriptionEn, $comparison);
    }

    /**
     * Filter the query on the type column
     *
     * Example usage:
     * <code>
     * $query->filterByType('fooValue');   // WHERE type = 'fooValue'
     * $query->filterByType('%fooValue%'); // WHERE type LIKE '%fooValue%'
     * </code>
     *
     * @param     string $type The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return ApplicationDataDefsQuery The current query, for fluid interface
     */
    public function filterByType($type = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($type)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $type)) {
                $type = str_replace('*', '%', $type);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(ApplicationDataDefsPeer::TYPE, $type, $comparison);
    }

    /**
     * Filter the query on the value_type column
     *
     * Example usage:
     * <code>
     * $query->filterByValueType('fooValue');   // WHERE value_type = 'fooValue'
     * $query->filterByValueType('%fooValue%'); // WHERE value_type LIKE '%fooValue%'
     * </code>
     *
     * @param     string $valueType The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return ApplicationDataDefsQuery The current query, for fluid interface
     */
    public function filterByValueType($valueType = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($valueType)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $valueType)) {
                $valueType = str_replace('*', '%', $valueType);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(ApplicationDataDefsPeer::VALUE_TYPE, $valueType, $comparison);
    }

    /**
     * Filter the query on the default_value column
     *
     * Example usage:
     * <code>
     * $query->filterByDefaultValue('fooValue');   // WHERE default_value = 'fooValue'
     * $query->filterByDefaultValue('%fooValue%'); // WHERE default_value LIKE '%fooValue%'
     * </code>
     *
     * @param     string $defaultValue The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return ApplicationDataDefsQuery The current query, for fluid interface
     */
    public function filterByDefaultValue($defaultValue = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($defaultValue)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $defaultValue)) {
                $defaultValue = str_replace('*', '%', $defaultValue);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(ApplicationDataDefsPeer::DEFAULT_VALUE, $defaultValue, $comparison);
    }

    /**
     * Filter the query on the last_modified column
     *
     * Example usage:
     * <code>
     * $query->filterByLastModified('2011-03-14'); // WHERE last_modified = '2011-03-14'
     * $query->filterByLastModified('now'); // WHERE last_modified = '2011-03-14'
     * $query->filterByLastModified(array('max' => 'yesterday')); // WHERE last_modified > '2011-03-13'
     * </code>
     *
     * @param     mixed $lastModified The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return ApplicationDataDefsQuery The current query, for fluid interface
     */
    public function filterByLastModified($lastModified = null, $comparison = null)
    {
        if (is_array($lastModified)) {
            $useMinMax = false;
            if (isset($lastModified['min'])) {
                $this->addUsingAlias(ApplicationDataDefsPeer::LAST_MODIFIED, $lastModified['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($lastModified['max'])) {
                $this->addUsingAlias(ApplicationDataDefsPeer::LAST_MODIFIED, $lastModified['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(ApplicationDataDefsPeer::LAST_MODIFIED, $lastModified, $comparison);
    }

    /**
     * Filter the query on the created column
     *
     * Example usage:
     * <code>
     * $query->filterByCreated('2011-03-14'); // WHERE created = '2011-03-14'
     * $query->filterByCreated('now'); // WHERE created = '2011-03-14'
     * $query->filterByCreated(array('max' => 'yesterday')); // WHERE created > '2011-03-13'
     * </code>
     *
     * @param     mixed $created The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return ApplicationDataDefsQuery The current query, for fluid interface
     */
    public function filterByCreated($created = null, $comparison = null)
    {
        if (is_array($created)) {
            $useMinMax = false;
            if (isset($created['min'])) {
                $this->addUsingAlias(ApplicationDataDefsPeer::CREATED, $created['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($created['max'])) {
                $this->addUsingAlias(ApplicationDataDefsPeer::CREATED, $created['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(ApplicationDataDefsPeer::CREATED, $created, $comparison);
    }

    /**
     * Filter the query by a related ApplicationDataSets object
     *
     * @param   ApplicationDataSets|PropelObjectCollection $applicationDataSets The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   ApplicationDataDefsQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByApplicationDataSets($applicationDataSets, $comparison = null)
    {
        if ($applicationDataSets instanceof ApplicationDataSets) {
            return $this
                ->addUsingAlias(ApplicationDataDefsPeer::APPLICATION_DATA_SET_ID, $applicationDataSets->getId(), $comparison);
        } elseif ($applicationDataSets instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(ApplicationDataDefsPeer::APPLICATION_DATA_SET_ID, $applicationDataSets->toKeyValue('PrimaryKey', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByApplicationDataSets() only accepts arguments of type ApplicationDataSets or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the ApplicationDataSets relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return ApplicationDataDefsQuery The current query, for fluid interface
     */
    public function joinApplicationDataSets($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('ApplicationDataSets');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'ApplicationDataSets');
        }

        return $this;
    }

    /**
     * Use the ApplicationDataSets relation ApplicationDataSets object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   ApplicationDataSetsQuery A secondary query class using the current class as primary query
     */
    public function useApplicationDataSetsQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinApplicationDataSets($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'ApplicationDataSets', 'ApplicationDataSetsQuery');
    }

    /**
     * Filter the query by a related UserApplicationData object
     *
     * @param   UserApplicationData|PropelObjectCollection $userApplicationData  the related object to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   ApplicationDataDefsQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByUserApplicationData($userApplicationData, $comparison = null)
    {
        if ($userApplicationData instanceof UserApplicationData) {
            return $this
                ->addUsingAlias(ApplicationDataDefsPeer::ID, $userApplicationData->getApplicationDataDefId(), $comparison);
        } elseif ($userApplicationData instanceof PropelObjectCollection) {
            return $this
                ->useUserApplicationDataQuery()
                ->filterByPrimaryKeys($userApplicationData->getPrimaryKeys())
                ->endUse();
        } else {
            throw new PropelException('filterByUserApplicationData() only accepts arguments of type UserApplicationData or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the UserApplicationData relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return ApplicationDataDefsQuery The current query, for fluid interface
     */
    public function joinUserApplicationData($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('UserApplicationData');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'UserApplicationData');
        }

        return $this;
    }

    /**
     * Use the UserApplicationData relation UserApplicationData object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   UserApplicationDataQuery A secondary query class using the current class as primary query
     */
    public function useUserApplicationDataQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinUserApplicationData($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'UserApplicationData', 'UserApplicationDataQuery');
    }

    /**
     * Exclude object from result
     *
     * @param   ApplicationDataDefs $applicationDataDefs Object to remove from the list of results
     *
     * @return ApplicationDataDefsQuery The current query, for fluid interface
     */
    public function prune($applicationDataDefs = null)
    {
        if ($applicationDataDefs) {
            $this->addUsingAlias(ApplicationDataDefsPeer::ID, $applicationDataDefs->getId(), Criteria::NOT_EQUAL);
        }

        return $this;
    }

}
